<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="订单号">
              <a-input placeholder="请输入订单号" v-model="queryParam.customerOrderNo"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="运单号">
              <a-input placeholder="请输入运单号" v-model="queryParam.waybillNo"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="12">
            <a-form-item label="到仓时间">
              <a-range-picker v-model="queryParamOther.toWarehouseTimeRange" :default-value="[queryParam.toWarehouseTime_begin, queryParam.toWarehouseTime_end]"   @change="effectToWarehouseTimeChange"  show-time style="width: 100%" valueFormat="YYYY-MM-DD HH:mm:ss" />
            </a-form-item>
          </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="物流商">
                <j-search-select-tag placeholder="请选择物流商" v-model="queryParam.providerId" dict="hz_logistics_provider,name,id,logistics,is_enable='Y'"></j-search-select-tag>
              </a-form-item>
            </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset_" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
       <a-button type="primary" icon="download" @click="handleExportXls('仓库入库信息')">导出</a-button>
      <!-- 高级查询区域 -->
      <!-- <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown> -->
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;" :preview="0"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

      </a-table>
    </div>

  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import { getAction, postFormAction } from '@/api/manage'
  import moment from 'moment/moment'

  export default {
    name: 'LogisticsWarehouseList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
    },
    data () {
      return {
        description: '物流产品管理页面',
        queryParamOther: {},
        queryParam: {
          toWarehouseTime_begin: moment(moment().subtract(1, 'month').startOf('day')).format('YYYY-MM-DD HH:mm:ss'),
          toWarehouseTime_end: moment(moment().endOf('day')).format('YYYY-MM-DD HH:mm:ss')
        },
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'订单号',
            align:"center",
            dataIndex: 'customerOrderNo',
          },
          {
            title:'运单号',
            align:"center",
            dataIndex: 'waybillNo'
          },
          {
            title:'是否拦截',
            align:"center",
            dataIndex: 'interceptStatus_dictText'
          },
          {
            title:'重量',
            align:"center",
            dataIndex: 'warehouseTestWeight'
          },
          {
            title:'到仓时间',
            align:"center",
            dataIndex: 'toWarehouseTime'
          },
          {
            title:'物流商',
            align:"center",
            dataIndex: 'providerId_dictText'
          },
          {
            title:'公司',
            align:"center",
            dataIndex: 'sysOrgCode_dictText'
          }
        ],
        url: {
          list: "/logistics/warehouse/shipment/list",
          exportXlsUrl: "/logistics/warehouse/shipment/exportExcel",
        },
        dictOptions:{},
        // superFieldList:[],
      }
    },
    created() {
    },
    computed: {
    },
    methods: {
      effectToWarehouseTimeChange(){
        this.queryParam.toWarehouseTime_begin = this.queryParamOther.toWarehouseTimeRange && this.queryParamOther.toWarehouseTimeRange[0];
        this.queryParam.toWarehouseTime_end = this.queryParamOther.toWarehouseTimeRange && this.queryParamOther.toWarehouseTimeRange[1];
      },
      searchReset_(){
        //重置页面展示异常问题
        this.queryParam = {
          toWarehouseTime_begin: moment(moment().subtract(1, 'month').startOf('day')).format('YYYY-MM-DD HH:mm:ss'),
          toWarehouseTime_end: moment(moment().endOf('day')).format('YYYY-MM-DD HH:mm:ss')
        }
        this.loadData(1);
      }
    }
  }
</script>
<style scoped lang="less">
  @import '~@assets/less/common.less';
  .costPriceId{
    text-align: left;
    position: relative;
    .tag{
      color: #fff;
      background-color: #ff6700;
      border-radius: 4px;
      padding: 1px 2px;
      font-size: 0.6rem;
      position: absolute;
      left: -6px;
      top: -18px;
    }
  }
  .active, .active_{
    position: relative;
    &::after{
      content: '';
      display: block;
      width: 5px;
      height: 5px;
      border-radius: 50%;
      background-color: #ff6700;
      position: absolute;
      top: 0;
      right: 11px;
    }
  }
  .active_{
    &::after{
      top: 8px;
      right: 6px;
    }
  }
</style>